import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { judgePortName } from '@/units'

const popupContent = ref()
const jumpUrlList = ref({
  park: {
    0: '',
    1: '/zfneed/demand-details/',
    2: '/zfcultivate/report-details/',
    3: '/zfcultivate/report-details/',
    4: '/zfservice/financial/',
    5: '/zfservice/knowledge-examine',
    6: '/zftalent/talent-examine',
    7: '/zfnotice/notice-details/',
    8: '/zfnotice/notice-details/',
    9: '/zfgovernment/government/',
    10: '/zfsafety/safety/',
    11: '',
    12: '',
    13: '',
    14: '/zfcultivate/report-details/',
    15: '',
    16: '/zfnotice/notice-details/',
    17: '/zfcultivate/cultivate/',
    18: '/zfeconomic/enterprise/',
    19: '/zfeconomic/enterprise/',
    20: '',
  },
  enterprise: {
    0: '',
    1: '/qyneed/fill-details/',
    2: '/qyproject/own-details/',
    3: '/qyproject/report-details/',
    4: '/qyfinancial/institution/',
    5: '/qyknowledge/service/',
    6: '',
    7: '/qynotice/park-details/',
    8: '/qynotice/park-details/',
    9: '',
    10: '',
    11: '',
    12: '',
    13: '/qyproject/evaluate/',
    14: '/qyproject/own-details/',
    15: '',
    16: '/qynotice/park-details/',
    17: '/qycultivate/cultivate/',
    18: '/qyenterprise-details/',
    19: '/qyenterprise-details/',
    20: '/qyfinancial/institution/',
    21: '/qymanage/list',
  },
})
const jumpUrl = () => {
  const router = useRouter()
  const handleJump = (typeId, detailId, data) => {
    popupContent.value = ''
    const loginMode = judgePortName()
    if (loginMode == 'park') {
      if (typeId == 4) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}`,
          query: {
            number: 3,
          },
        })
      } else if (typeId == 7 || typeId == 8 || typeId == 16) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}${detailId}`,
          query: {
            type: typeId == 16 ? 2 : typeId == 7 ? 4 : 3,
          },
        })
      } else if (typeId == 1 || typeId == 2 || typeId == 3 || typeId == 14) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}${detailId}`,
        })
      } else if (typeId == 18 || typeId == 19) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}`,
          query: {
            activeTopType: typeId == 18 ? 1 : 2,
          },
        })
        // router.push({
        //   path: `${jumpUrlList.value[loginMode][typeId]}${detailId}`,
        //   query: {
        //     fatherTab: 5,
        //     sonTab: typeId == 18 ? 1 : 2,
        //   },
        // })
      } else {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}`,
        })
      }
    } else {
      if (
        typeId == 1 ||
        typeId == 2 ||
        typeId == 3 ||
        typeId == 7 ||
        typeId == 8 ||
        typeId == 16
      ) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}${detailId}`,
        })
      } else if (typeId == 19 || typeId == 18) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}${detailId}`,
          query: {
            fatherTab: 5,
            sonTab: typeId == 18 ? 1 : 2,
          },
        })
      } else if (typeId == 21) {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}`,
        })
      } else if (typeId == 6) {
        // 审核被拒绝
        popupContent.value = {
          title: '恭喜您，审核已通过',
          content: [
            {
              label: `您于 ${data.data.submissionTime} 提交的“人才服务机构”的申请`,
            },
            {
              label: `已于 ${data.data.auditTime} 被受理，已通过审核`,
            },
            // {
            //   label: '审核意见：通过',
            // },
          ],
        }
      } else if (typeId == 9 || typeId == 15 || typeId == 13 || typeId == 14) {
        let title =
          typeId == 9
            ? '政务咨询留言反馈'
            : typeId == 15
            ? '资源匹配留言反馈'
            : typeId == 13
            ? '企业自评留言反馈'
            : '项目申报留言反馈'
        // 留言反馈
        popupContent.value = {
          title: title,
          content: [
            {
              label: '留言内容：',
              time: '留言时间：' + data.data.submissionTime,
              value: data.data.title,
            },
            {
              label: '反馈信息：',
              time: '反馈时间：' + data.data.feedbackTime,
              value: '回复：' + data.data.replyContent,
            },
          ],
        }
      } else if (typeId == 11 || typeId == 12) {
        // 审核被拒绝
        popupContent.value = {
          title:
            data.data.state == 2 ? '很遗憾，审核未通过' : '恭喜您，审核已通过',
          content: [
            {
              label: `您于 ${data.data.submissionTime} 提交的“成为${
                typeId == 11 ? '产权服务机构' : '人才服务机构'
              }”的申请`,
            },
            {
              label: `已于 ${data.data.auditTime} 被受理，但${
                data.data.state == 2 ? '未' : '已'
              }通过审核`,
            },
            {
              label: !data.data.notes ? '' : '审核意见：' + data.data.notes,
            },
          ],
        }
      } else {
        router.push({
          path: `${jumpUrlList.value[loginMode][typeId]}`,
        })
      }
    }
  }
  return {
    popupContent,
    handleJump,
  }
}
export { jumpUrl }
